package main

import fmt "fmt"
import time "time"

func main() {
	ch := make(chan int, 1)
	//
	// for {
	// 	select {
	// 	case ch <- 0:
	// 	case ch <- 1:
	// 	}
	//
	// 	i := <-ch
	// 	fmt.Println("Value Received:", i)
	// }

	timeout := make(chan bool, 1)

	go func() {
		time.Sleep(1e9) // 1s
		timeout <- true
	}()

	select {
	case <-ch:
	case <-timeout:
	}

	close(timeout) //关闭channel

	fmt.Println("time out")
}
